
<template>
<div>
  <el-steps :active="3" align-center>
    <el-step title="填写课程基本信息" ></el-step>
    <el-step title="创建课程大纲"></el-step>
    <el-step title="最终发布" ></el-step>
  </el-steps>
  <div>
        <div class="grid-content bg-purple-dark">
          <el-card class="box-card">
            <div style="float: left;margin-top: -60px;margin-left: 30px" >
              <h1>{{form.title}}</h1>
              <h3>共{{form.lessonNum}}课时</h3>
              <h3>所属分类:{{form.subjectParentName}}_{{form.subjectName}}</h3>
              <h3>课程讲师:{{form.teacherName}}</h3>
              <h2 style="color: red">￥{{form.price}}</h2>
            </div>
            <div  style="float: left" slot="header" class="clearfix">
              <img  :src="form.cover" class="avatar">
            </div>
          </el-card>
        </div>
      </div>
  <el-button @click="fanhui()">返回上一步</el-button>
  <el-button type="primary" @click="next()">发布课程</el-button>
</div>
</template>
<script>
import {getpublic,getfabu} from '@/api/course'
export default {
  data() {
    return {
      courseid:'',
      form:{
        cover:'',
        title:'',
        subjectParentName:'',
        subjectName:'',
        teacherName:'',
        lessonNum:'',
        price:''
      }
    };
  },
  methods: {
    next(){
      getfabu(this.courseid).then(res=>{
        if (res.code==20000){
          this.$message.success("发布成功!")
          this.$router.push ({path:"/course/list"})
        }else{
          this.$message.success("发布失败!")
        }
      })
    },
    fanhui(){
      this.$router.push ({path:"/course/chapter",query:{id:this.$route.query.courseid}})
    },
   gethx(){
     getpublic(this.courseid).then(res=>{
       if (res.code==20000){
         this.form.cover=res.data.cover
         this.form.title=res.data.title
         this.form.subjectParentName=res.data.subjectParentName
         this.form.price=res.data.price
         this.form.lessonNum=res.data.lessonNum
         this.form.teacherName=res.data.teacherName
         this.form.subjectName=res.data.subjectName
       }
     })
   }
  },
  created() {
    this.courseid=this.$route.query.courseid
    this.gethx()
  }
}
</script>
<style scoped lang="scss">

</style>
